Hey guys!
I am new to the forum and want to say hi to everybody!
Currently I am working on an exercise to draw a national flag by using while and if statements. I am learning the programming language in own efforts, so I am not attending any school or what so ever.
Alright to point out my problem:
I wrote a function to draw the flag I desired (Danish flag). Unfortunately it only draws the very first row and I don't understand why it is only drawing the first row. I would be really grateful to get some hints what I actually did with the code to behave that way. This is the code:
Code:
/* Create a Danish Flag with the use of loops and functions
*/
/*
* File: main.c
* Author: Epi
*
* Created on 20. Mai 2016, 18:29
*/
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 11
#define HEIGHT 6
void drawFlag (int width, int height);
int main(int argc, char** argv) {
int width = WIDTH;
int height = HEIGHT;
drawFlag (width, height);
return (EXIT_SUCCESS);
}
void drawFlag (int width, int height){
int counter = 0;
int drawHeight = 0;
int drawWidth = 0;
while (drawHeight < height){
if (drawHeight != 3 || drawWidth != 4){
while (counter < width){
if (counter == 3){
printf (" ");
}else{
printf ("*");
}
counter++;
}
}else{
while (counter < width){
printf (" ");
counter++;
}
}
printf ("\n");
drawHeight++;
drawWidth++;
}
}
Edit: sry i cant get rid of the first code window, it reappears all the time. Cheers!